var protocol = (function() {
	
	//Function to multiply certain parameter
	//Params: name, ref, times
	function volumeMultiply(ref, name, times){
		times = typeof times !== 'undefined' ? times : 1;
		times = parseFloat(times);
		storage[name] = times*storage[ref];
		return storage[name];
	}

	function selected(bin){
		var value = selected_items[bin].length === undefined ? 0 : selected_items[bin].length;
		return value;
	}

	//Function to multiply slider value by certain times
	//Params: name, times, slider
	function Slider(slider, name){
		name = typeof name !== 'undefined' ? name : '';
		if(name){
			storage[name] = $("#"+slider).slider("value");
		}
		return {
			valueOf: function() {return $("#"+slider).slider("value"); }
		};
	}

	function attribMultiply(attrib){
		return {
			//protocol_template.value references to item from selected_items
			valueOf: function() {return parseFloat(protocol_template.value[attrib]);}
		};
	}

	function isVolume(Quantity){
		return true;
	}

	function volume(value, unit){
		unit = typeof unit !== 'undefined' ? unit : '';
		var units = {n: Math.pow(10,9),u: Math.pow(10,6),m: Math.pow(10,3),c: Math.pow(10,2),d: Math.pow(10,1)};
		multiply = unit !== '' ? (unit.length > 1 ? units[unit[0]] : units[unit]) : 1;
		return value*multiply+unit;
	}

	var storage = {};
	var options = {};

	return {
		options: function(key, value){
			options[key] = value;
		},
		%s
	};
}());
